package lib.quasar.widget.chart.draw;

import android.content.Context;
import android.graphics.Canvas;

import lib.quasar.widget.chart.ChartView;
import lib.quasar.widget.chart.paint.StockPaint;

/**
 * description: 当前类描述信息
 * created by kalu on 2018/4/29 8:33
 */
public final class DrawNull implements IDraw {

    private float left, right, top, bottom;
    private float marginLeft, marginRight, marginTop, marginBottom;
    private float width, height, centerX, centerY;
    private float paddingLeft, paddingTop, paddingRight, paddingBottom;

    @Override
    public void onDrawInit(float left, float top, float right, float bottom,
                           float marginLeft, float marginTop, float marginRight, float marginBottom,
                           float paddingLeft, float paddingTop, float paddingRight, float paddingBottom,
                           float width, float height, float centerX, float centerY, int model) {

        if (model != ChartView.DRAW_TEMPERATURE) return;

        this.left = left;
        this.right = right;
        this.top = top;
        this.bottom = bottom;

        this.marginLeft = marginLeft;
        this.marginTop = marginTop;
        this.marginRight = marginRight;
        this.marginBottom = marginBottom;

        this.paddingLeft = paddingLeft;
        this.paddingTop = paddingTop;
        this.paddingRight = paddingRight;
        this.paddingBottom = paddingBottom;

        this.width = width;
        this.height = height;
        this.centerX = centerX;
        this.centerY = centerY;
    }

    @Override
    public void onDrawNull(Context context, ChartView chart, Canvas canvas, String hint, int model) {

        if (model != ChartView.DRAW_TEMPERATURE) return;

        canvas.save();
        drawBackground(context, chart, canvas, hint);
        canvas.restore();
    }

    @Override
    public void onDrawData(Context context, ChartView chart, Canvas canvas, float xHighligh, float yHighligh, int model) {

        if (model != ChartView.DRAW_TEMPERATURE) return;
    }

    private void drawBackground(Context context, ChartView chart, Canvas canvas, String hint) {

        canvas.drawRect(left, top, right, bottom, StockPaint.getRectPaint());
        canvas.drawText(hint, centerX, centerY, StockPaint.getHintPaint());
    }
}